<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_sys_class('model', '', 0);

class site_setting_model extends model
{

    public $table_name = '';

    public function __construct()
    {
        $this->db_config = pc_base::load_config('database');
        $this->db_setting = 'default';
        $this->table_name = 'site_setting';
        parent::__construct();
    }

    public function getValue($key, $siteid)
    {
        $value = $this->get_one(array(
            "s_key" => $key,
            'site' => $siteid
        ), "type,s_value");
        if (empty($value)) {
            return false;
        }
        if ($value['type'] == 1) {
            return trim($value['s_value']);
        }
        if ($value['type'] == 2) {
            return json_decode(trim($value['s_value']), true);
        }
        if ($value['type'] == 3) {
            return explode("|", trim($value['s_value']));
        }
    }
}
?>
